package com.cy.store.repository;

import com.cy.store.entity.District;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface DistrictRepository extends JpaRepository<District, Integer> {

    //根据parent去查找目标
    List<District> findAllByParentOrderByCodeAsc(String parent);

    //根据code获取名称
    @Query(value = "select name from district where code=?1 ", nativeQuery = true)
    String findNameByCode(String code);

}
